package com.gitee.swsk33.springannotationbased.config;

import com.gitee.swsk33.logcoredemo.config.LogConfig;
import com.gitee.swsk33.logcoredemo.service.LogService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 用于日志外部库的配置类：将日志库中需要的类注册为Bean
 */
@Configuration
public class LogServiceConfig {

	/**
	 * 实例化一个日志配置类，并设定配置，然后注册为Bean
	 */
	@Bean
	public LogConfig logConfig() {
		LogConfig config = new LogConfig();
		// 设定显示时间
		config.setShowTime(true);
		return config;
	}

	/**
	 * 将LogService类实例化，并注册为Bean，并注入配置对象依赖
	 */
	@Bean
	public LogService logService(LogConfig logConfig) {
		LogService logService = new LogService();
		logService.setConfig(logConfig);
		return logService;
	}

}